import { defineStore } from "pinia";
import { UserState } from "@/stores/interface";
import piniaPersistConfig from "@/stores/helper/persist";

export const useUserStore = defineStore({
  id: "sys-user",
  state: (): UserState => ({
    token: "",
    userInfo: { name: "admin", id: 0, username: "", display_name: "" }
  }),
  getters: {
    userInfoGet: state => state.userInfo
  },
  actions: {
    // Set Token
    setToken(token: string) {
      this.token = token;
    },
    // Set setUserInfo
    setUserInfo(userInfo: any) {
      this.userInfo = userInfo;
    }
  },
  persist: piniaPersistConfig("sys-user")
});
